import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jinke/utils/util.dart';

import 'logic.dart';

class Report_editPage extends StatelessWidget {
  final logic = Get.find<ReportDetailLogic>();
  final state = Get.find<ReportDetailLogic>().state;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: BackButton(color: Colors.white,),
        title: Text('日报详情',style: TextStyle(color: Colors.white,fontSize: 17.r),),
        centerTitle: true,
        backgroundColor: ColorsUtil.blue,
      ),
      body: Column(
        children: [
          Expanded(child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                SizedBox(height: 20.r,),
                Text('金水科教园招商引资项目推进工作日报',style: TextStyle(color: ColorsUtil.title,fontSize: 18.r,fontWeight: FontWeight.bold),),
                SizedBox(height: 10.r,),
                Text('2022',style: TextStyle(color: ColorsUtil.title,fontSize: 18.r,fontWeight: FontWeight.bold),),

                ListView.builder(itemBuilder: (context,index){
                  state.detailentityList[index].editReportEvolveContent = state.detailentityList[index].reportEvolveContent;
                  return Container(
                    width: 343.r,
                    margin: EdgeInsets.fromLTRB(0.r, 5.r, 0.r, 0),
                    padding: EdgeInsets.all(13.r),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(state.detailentityList[index].projectAlias??'',style: TextStyle(color: Color(0xff333333),fontSize: 16.r,fontWeight: FontWeight.bold),),
                        SizedBox(height: 10.r,),
                        Row(
                          children: [
                            BrnStateTag(
                              tagText: state.detailentityList[index].projectPhaseCn??'',
                              tagState: TagState.invalidate,

                            ),
                            SizedBox(width: 10.r,),
                            BrnStateTag(
                              tagText: state.detailentityList[index].phaseStatusCn??'',
                              tagState: TagState.failed,
                            ),
                          ],
                        ),
                        Container(
                          margin: EdgeInsets.only(top: 15.r),
                          child: BrnInputText(
                            maxHeight: 200.r,
                            minHeight: 50.r,
                            minLines: 5,
                            maxLength: 500,
                            bgColor: Colors.white,
                            textString: state.detailentityList[index].reportEvolveContent??'',
                            textInputAction: TextInputAction.newline,
                            maxHintLines: 20,
                            borderColor: Color(0xffeeeeee),
                            autoFocus: false,
                            hint: '请输入',
                            padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
                            onTextChange: (text) {
                              state.detailentityList[index].editReportEvolveContent = text;
                            },
                          ),
                        ),
                      ],
                    ),
                  );
                },itemCount: state.detailentityList.length,shrinkWrap: true,physics: const NeverScrollableScrollPhysics(),)
              ],
            ),
          )),
          Row(
            children: [

              Expanded(child: GestureDetector(
                onTap: (){
                  Get.back();
                },
                child: Container(
                  height: 55.r,
                  margin: EdgeInsets.only(left: 0.5,right: 0.5),
                  color: Colors.white,
                  child: Center(child: Text('取消本次编辑',style: TextStyle(color: Color(0xff333333),fontSize: 15.r,fontWeight: FontWeight.w500),),),
                ),
              )),
              Expanded(child: GestureDetector(
                onTap: (){
                  BrnDialogManager.showConfirmDialog(
                    Get.context!,
                    title: "提示",
                    cancel: '取消',
                    confirm: '确定',
                    message: "确定提交本次编辑？",
                    onConfirm: () {
                      Get.back();
                      logic.batchSave();
                    },
                    onCancel: () {
                      Get.back();
                    },
                  );
                },
                child: Container(
                  height: 55.r,
                  decoration: BoxDecoration(
                    gradient: const LinearGradient(      //渐变位置
                        begin: Alignment.centerLeft, //右上
                        end: Alignment.centerRight, //左下
                        stops: [0.0, 1.0],         //[渐变起始点, 渐变结束点]
                        //渐变颜色[始点颜色, 结束颜色]
                        colors: [Color(0xff00A9FE), Color(0xFF0173FE)]
                    ),
                    color: Colors.white,
                  ),

                  child: Center(child: Text('完成',style: TextStyle(color: Colors.white,fontSize: 15.r,fontWeight: FontWeight.w500),),),
                ),
              )),
            ],
          )
        ],
      ),
    );
  }
}
